﻿using UnityEngine;
using System.Collections;

public class AnswerLabel2 : MonoBehaviour {

	// Use this to save answer
	string answerString = null;

	// Set style for text label
	public Texture2D[] answerLabel;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnGUI(){
		if (Program.isClicked == true && QuestionLabel.questionIndex < 10) {
			if(AnswerLabel1.randomNumberList[QuestionLabel.questionIndex] != 0){
				answerString = QuestionLabel.calculatorList [QuestionLabel.questionIndex].getCorrectAnswer ();
				if(answerString.Equals("+")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 + 71,
					                      gameObject.transform.position.y +Screen.height - 63, 50, 50), answerLabel[0], GUIStyle.none);
				}else if(answerString.Equals("-")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 + 71,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[1], GUIStyle.none);
				}else if(answerString.Equals("*")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 + 71,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[2], GUIStyle.none);
				}else{
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 + 71,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[3], GUIStyle.none);
				}
				
			}else{
				answerString = QuestionLabel.calculatorList [QuestionLabel.questionIndex].getInCorrectAnswer ();;
				if(answerString.Equals("+")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 + 71,
					                      gameObject.transform.position.y +Screen.height - 63, 50, 50), answerLabel[0], GUIStyle.none);
				}else if(answerString.Equals("-")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 + 71,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[1], GUIStyle.none);
				}else if(answerString.Equals("*")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 + 71,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[2], GUIStyle.none);
				}else{
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 + 71,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[3], GUIStyle.none);
				}
			}
		}
	}
}
